import CryptoJS from 'crypto-js'
import md5 from "./md5.js"
const decryptData = (encryptedData, key, iv) => {
	console.log(encryptedData, key, iv)
	const decrypted = CryptoJS.AES.decrypt({
		ciphertext: encryptedData,
	}, key, {
		iv: iv,
		padding: CryptoJS.pad.Pkcs7,
		mode: CryptoJS.mode.CBC
	});
	console.log(decrypted.toString(CryptoJS.enc.Utf8), 'js')
	return decrypted.toString(CryptoJS.enc.Utf8);

}

const cryptData = (encryptedData, key, iv) => {
		console.log(encryptedData, key, iv)
const encrypt =	CryptoJS.AES.encrypt(encryptedData, key, {
		iv: iv,
		mode: CryptoJS.mode.CBC, //aes加密模式cbc
		padding: CryptoJS.pad.Pkcs7 //填充
	});
	console.log(encrypt,'js')
return encrypt.toString();
}

export default {
	decryptData,
	cryptData
}